package com.shanglv.member.service.demo.impl;


import javax.ws.rs.core.Response;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.shanglv.dto.flight.demo.DemoDto;
import com.shanglv.member.model.Demo;
import com.shanglv.member.repository.demo.DemoRepository;
import com.shanglv.member.service.demo.DemoService;

@Component("demoService")
public class DemoServiceImpl implements DemoService {
	
	@Autowired
	private DemoRepository demoRepository;

	public Response addDemo(DemoDto demo) {
		demoRepository.addDemo(new Demo(demo));
		return Response.ok().build();
	}

	public Response deleteDemo(Integer id) {
		demoRepository.deleteById(id);
		return Response.ok().build();
	}

	public Response updateDemo(DemoDto demo) {
		demoRepository.updateDemo(new Demo(demo));
		return Response.ok().build();
	}

	public Response getDemo(Integer id) {
		Demo demo = demoRepository.getById(id);
		return Response.ok().entity(demo.toDto()).build();
	}

}
